﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using JustBlog.Core.Entities;

namespace JustBlog
{
    public static class Extensions
    {
        public static string ToConfiguLocalTime(this DateTime utcDT)
        {
            //var istTZ = TimeZoneInfo.FindSystemTimeZoneById(ConfigurationManager.AppSettings["Timezone"]);
            //return String.Format("{0} ({1})",
            //    TimeZoneInfo.ConvertTimeFromUtc(utcDT, istTZ).ToShortDateString(),
            //    ConfigurationManager.AppSettings["TimezoneAbbr"]);
            return utcDT.ToString("yyyy-MM-dd HH:mm:ss");
        }

        public static string Href(this Post post, UrlHelper helper)
        {
            return helper.RouteUrl(new
            {
                controller = "Blog",
                action = "Post",
                year = post.PostedOn.Year,
                month = post.PostedOn.Month,
                title = post.UrlSlug
            });
        }
    }
}